package com.six.remark.controller;

import com.six.core.entity.Remark;
import com.six.core.vo.Result;
import com.six.remark.service.RemarkService;
import com.six.remark.vo.SearchRemark;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ClassName:RemarkController
 * Description:
 * date:2023/2/27 17:20
 *
 * @since JDK 1.8
 */
@Api(value = "remark/remark", tags = {"ClassName:RemarkController Description: date:2023/2/27 17:20"})
@RestController
@RequestMapping("remark/remark")
public class RemarkController {
    @Autowired
    private RemarkService remarkService;
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "body", dataType = "SearchRemark", name = "searchRemark", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "currentPage", value = "", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @PostMapping("findAll")
    public Result findAll(@RequestBody SearchRemark searchRemark, @RequestParam(defaultValue = "1") Integer currentPage, @RequestParam(defaultValue = "5")Integer pageSize){
        return remarkService.findAll(searchRemark,currentPage,pageSize);
    }
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "id", value = "", required = true)
    })
    @ApiOperation(value = "", notes = "", httpMethod = "POST")
    @PostMapping("deleteById")
    public Result deleteById(Integer id){
        return remarkService.deleteById(id);
    }
    @PostMapping("insertRemark")
    public Result insertRemark(@RequestBody Remark remark){
        return remarkService.insertRemark(remark);
    }
    @PostMapping("updateRemark")
    public Result updateRemark(@RequestBody Remark remark){
        return remarkService.update(remark);
    }
}
